package cn.iocoder.yudao.module.system.controller.admin.user;

import cn.iocoder.yudao.framework.excel.core.function.ExcelColumnSelectFunction;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
import jakarta.annotation.Resource;
import org.hibernate.validator.constraints.Range;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 公司下拉框数据源的 {@link ExcelColumnSelectFunction} 实现类
 *
 * @author HUIHUI
 */
@Service
public class YmDeptExcelFunction implements ExcelColumnSelectFunction {

    @Resource
    private DeptMapper deptMapper;

    public static final String NAME = "getYmDeptNameList"; // 防止和别的模块重名

    @Override
    public String getName() {
        return NAME;
    }

    @Override
    public List<String> getOptions() {
        List<String> strings = new ArrayList<>();

        List<DeptDO> deptDOS = deptMapper.selectList();
        if(deptDOS != null && !deptDOS.isEmpty()){
            for (DeptDO deptDO : deptDOS) {
                strings.add(deptDO.getName());
            }
        }
        return strings;
    }

}